Tomtom: fix mem overwrite on comments > 255 chars.
authorrobertl <robertl>
Thu, 28 Feb 2008 15:40:50 +0000 (15:40 +0000)
committerrobertl <robertl>
Thu, 28 Feb 2008 15:40:50 +0000 (15:40 +0000)
tomtom.c

index 49f3b2ae0eb31e3e3c7552a63722856b6f982160..45ce10443128a754415c8b15d9a68cd3e86777fc 100644 (file)
--- a/tomtom.c
+++ b/tomtom.c
@@ -235,7 +235,7 @@ write_blocks( FILE *f, struct blockheader *blocks ) {
             if (global_opts.smart_names && 
                        blocks->start[i].wpt->gc_data.diff && 
                        blocks->start[i].wpt->gc_data.terr) {
-                snprintf(desc_field,256,"%s(t%ud%u)%s(type%dcont%d)",blocks->start[i].wpt->description,
+                snprintf(desc_field,sizeof(desc_field),"%s(t%ud%u)%s(type%dcont%d)",blocks->start[i].wpt->description,
                 blocks->start[i].wpt->gc_data.terr/10,
                 blocks->start[i].wpt->gc_data.diff/10,
                 blocks->start[i].wpt->shortname,
@@ -243,7 +243,8 @@ write_blocks( FILE *f, struct blockheader *blocks ) {
                 (int) blocks->start[i].wpt->gc_data.container);
                 //Unfortunately enums mean we get numbers for cache type and container.
             } else {
-                strcpy(desc_field,blocks->start[i].wpt->description);
+                snprintf(desc_field, sizeof(desc_field), "%s",
+                       blocks->start[i].wpt->description);
             }
                        write_long( f, strlen( desc_field ) + 14 );
                        write_float_as_long( f, blocks->start[i].wpt->longitude*100000);